var sendUrl = function(details) {
	console.log(details);
  chrome.tabs.getSelected(null, function(tab) {
	  console.log('sending message about track url');
      chrome.tabs.sendMessage(tab.id, {command:'trackUrlReceived',url:details.url});
  });
}

chrome.webRequest.onBeforeRequest.addListener(sendUrl, {urls: ["*://ec-media.soundcloud.com/*"]});


var trackData = function(details) {
	// track data is gotten
	console.log(details);
	chrome.tabs.getSelected(null, function(tab) {
		console.log('sending message about track data');
		chrome.tabs.sendMessage(tab.id, {command:'trackDataReceived',url:details.url});
	});
}

chrome.webRequest.onCompleted.addListener(trackData, {urls: ["*://api.sndcdn.com/tracks/*"]});


var playlistData = function(details) {
	// track data is gotten
	console.log(details);
	chrome.tabs.getSelected(null, function(tab) {
		console.log('sending message about playlist data');
		chrome.tabs.sendMessage(tab.id, {command:'playlistDataReceived',url:details.url});
	});
}

//chrome.webRequest.onCompleted.addListener(playlistData, {urls: ["*://api.sndcdn.com/users/*"]});